import groupItem from "../comm/groupItem.vue";
export default {
  name: "",
  //import引入的组件需要注入到对象中才能使用
  components: {
    groupItem,
  },
  data() {
    return {
      coursesId: "",
      chatStrId: "",
      datumObj: {
        groupName: "发送群数量",
        viewName: "观看次数",
        finishName: "完播次数",
        userName:'在线观看用户',
        liveMemberCount:'直播观看人数',
        backFinishRatio:'回放完播率',
        liveFinishRatio:'直播完播率',
        backMemberCount:'回放观看人数',
        finishRatio:'观看完播率',
        memberCountName:'观看人数',
        send_group_count: 0,
        watch_count: 0,
        watch_finish_count: 0,
        live_member_count:0,
        back_finish_ratio:0,
        live_finish_ratio:0,
        back_member_count:0,
        member_count:0,
        finish_ratio:0,
      },
      answerObj: {
        answerName: "答题正确次数",
        reply_right_count: 0,
        packethName: "红包发放金额",
        reward_price: "0.00"
      },
      courses: {}
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    lookTo(routeName) {
      this.$router.push(this.fun.getUrl(routeName, { id: this.coursesId }, {}));
    },
    coursesRecord() {
      let query = {
        courses_id: Number(this.coursesId)
      };
      console.log(query);
      if (this.fun.getKey("client") === "work" || window.localStorage.getItem("client")) {
        query = { ...this.getConfig, ...query, chat_str_id: this.chatStrId };
      }
      $http
        .post("plugin.wechat-video-courses.frontend.controller.manage.record.courses", query, "loading")
        .then(res => {
          if (res.result === 1) {
            let data = res.data;
            this.datumObj.send_group_count = data.send_group_count;
            this.datumObj.watch_count = data.watch_count; //观看次数
            this.datumObj.watch_finish_count = data.watch_finish_count;
            this.datumObj.live_member_count = data.live_member_count; //直播观看人数
            this.datumObj.live_finish_ratio = data.live_finish_ratio; //直播完播率
            this.datumObj.back_member_count = data.back_member_count;
            this.datumObj.back_finish_ratio = data.back_finish_ratio;
            this.datumObj.finish_ratio = data.finish_ratio; //观看完播率
            this.datumObj.member_count = data.member_count; //观看人数
            this.answerObj.reply_right_count = data.reply_right_count;
            this.answerObj.reward_price = data.reward_price;
            this.courses = data.courses;
            // this.classify = data.category_list;
          } else {
            this.$toast(res.msg);
          }
        })
        .catch(err => {
          console.log("getUserData::err", err);
        });
    }
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    if (this.fun.getKey("client") === "work" || window.localStorage.getItem("client")) {
      this.chatStrId = window.localStorage.getItem("chat_id") || "";
    }
    if (this.$route.params.id) {
      this.coursesId = this.$route.params.id;
      this.coursesRecord();
    }
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {} //如果页面有keep-alive缓存功能，这个函数会触发
};
